<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="org.dualr.litelog.entity.Photo"%>
<%@ page import="org.dualr.litelog.entity.Page"%>
<%@ page import="org.dualr.litelog.entity.Category"%>
<%@ page import="org.dualr.litelog.dao.CategoryDao"%>
<%@ page import="org.dualr.litelog.utils.LiteLogUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Photos - LiteLog Administration</title>
<link href="../admin/common.css" rel="stylesheet" type="text/css" media="screen"/>
</head>

<body>
<h1>图片管理</h1>
	<form action="../admin?entity=photo&option=upload" method="post" enctype="multipart/form-data">
			图片:<input type="file" name="photo" />
			<input type="submit" value="上传"></input>
	</form>
	<div>
	<table class="data-list" width="100%" cellspacing="0" cellpadding="0">
		<tr class="caption">
			<td width="28">序号</td>
			<td>分类</td>
			<td>图片名称</td>
			<td>日期</td>
			<td>查看</td>
			<td>编辑</td>
			<td>删除</td>
		</tr>
		<%
			List<Object[]> photoList = (List<Object[]>)request.getAttribute("photoList");
				if(photoList.size() != 0){
					int i=1;
					for(Object[] photo : photoList){
		%>
			<tr>
				<td><%=i++%></td>
				<td width="100">
				<%
					List<Category> categoryList = CategoryDao.getInstance().getListByProperty("type","photo","string");
						if (categoryList.size() != 0){
							for(Category category : categoryList){
								if(photo[4] == category.getId()){
									%>
										<%=category.getName()%>
									<%
								}
							}
						}
				%>
				</td>
				<td><a href="photo?id=<%=photo[0]%>" target="_blank"><%=photo[1]%></a></td>
				<td width="170"><%=photo[2].toString()%></td>
				<td width="30"><a href="photo?id=<%=photo[0].toString()%>" target="_blank">查看</a></td>
				<td width="30"><a href="admin?entity=photo&option=edit&id=<%=photo[0].toString()%>">编辑</a></td>
				<td width="30"><a href="admin?entity=photo&option=delete&id=<%=photo[0].toString()%>">删除</a></td>
			</tr>
		<%
					}
					Page pages = (Page)request.getAttribute("Page");
		%>
			<tr>
				<td colspan="7" id="page">
					记录数:<%=pages.getHits()%> [<a href="admin?entity=photo&option=list&page=<%=pages.getPrevPage()%>">上一页</a>]<%=pages.getCurPage()%>/<%=pages.getPageNum()%>[<a href="admin?entity=photo&option=list&page=<%=pages.getNextPage()%>">下一页</a>]
				</td>
			</tr>
		<%
				}else{
		%>
			<tr>
				<td>列表为空</td>
			</tr>
		<%
			}
		%>
	</table>
	</div>
</body>
</html>